package com.cgmnx.admin.service.rbac.impl;

import com.cgmnx.admin.common.bean.Limiter;
import com.cgmnx.admin.common.exception.Preconditions;
import com.cgmnx.admin.dao.condition.LogCondition;
import com.cgmnx.admin.dao.entity.rbac.OperationLogEntity;
import com.cgmnx.admin.dao.mapper.rbac.OperationLogMapper;
import com.cgmnx.admin.service.rbac.OperationLogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author created on 14-3-12 下午4:44
 * @version $Id$
 */
@Slf4j
@Service
public class OperationLogServiceImpl implements OperationLogService {

//    @Autowired
    private OperationLogMapper operationLogMapper;

    @Override
    public int save(OperationLogEntity entity) {

        return operationLogMapper.save(entity);
    }

    @Override
    public int saveAll(List<OperationLogEntity> entityList) {

        Preconditions.checkArgument(CollectionUtils.isEmpty(entityList), "日志信息不能为空");

        return operationLogMapper.saveAll(entityList);
    }

    @Override
    public List<OperationLogEntity> query(OperationLogEntity condition) {
        return null;
    }

    @Override
    public OperationLogEntity queryById(Integer id) {
        return null;
    }

    @Override
    public List<OperationLogEntity> queryPage(final LogCondition condition, Limiter limiter) {
        Preconditions.checkNotNull(limiter, "分页信息不能为空");
        return operationLogMapper.queryPage(condition, limiter);
    }


    @Override
    public int count(final LogCondition condition) {
        return operationLogMapper.count(condition);
    }


}
